package main

import "fmt"

type SliceInterface[T int] interface {
	Delete(index int) ([]T, error)
}

func (s Slice[T]) Delete(index int) ([]T, error) {
	count := len(s)
	if index >= count {
		panic("超过切片索引边界")
	}

	if index < 0 {
		panic("索引不能为负")
	}
	s = append(s[:index], s[index+1:]...)
	fmt.Println(len(s), cap(s))
	afterCount := len(s)
	afterSlice := make(Slice[T], afterCount, afterCount)
	copy(afterSlice, s)
	fmt.Println(len(afterSlice), cap(afterSlice))

	return afterSlice, nil
}

type Slice[T int] []T

func main() {
	s := Slice[int]{10, 20, 30, 40, 50, 60, 70, 80}
	s, err := s.Delete(0)
	if err != nil {
		return
	}
	fmt.Println(s)
}
